from selenium.webdriver.common.by import By as by


class ElementLocalization():
        """
        这个方法是将常用的元素定位都存储在里面
        免得每一个page都要写一次
        降低代码冗余度
        """
        # 零售管理
        retail_management = (by.XPATH, '(//div[@class="ant-menu-submenu-title"])[1]')

        # 零售退货
        retail_delivery = (by.XPATH, '//a[@target="零售退货"]')

        # 新增按钮
        new_order = (by.CSS_SELECTOR, '.table-operator .ant-btn-primary')

        # 点击引导关闭
        skip_button = (by.CSS_SELECTOR, '.introjs-skipbutton')

        # 会员卡号点击
        click_vip = (by.CSS_SELECTOR, '#organId')

        # 会员卡号输入框
        input_vip = (by.CSS_SELECTOR, '#organId .ant-select-search__field')

        # 关联单据按钮
        related_order = (by.XPATH,'//i[@aria-label="图标: search"and @tabindex="-1"]')

        # 选择最新商品
        select_new_product = (by.CSS_SELECTOR, 'tbody.ant-table-tbody:nth-child(3)>tr.ant-table-row:nth-of-type(1)')

        # 选择商品确定按钮
        select_new_product_determine = (by.XPATH, '(//button[@class="ant-btn ant-btn-primary"])[5]')

        # 选择单据明细
        """可能还需要验证一下"""
        select_order = (by.XPATH, '//*[@id="app"]/section/section/main/div[2]/div/div/div/div/div[4]/div/div/div[2]/div/div[2]/div[2]/div[2]/div/div/div[2]/div/div[2]/div[2]/div[1]/div/div/div/div/div/table/tbody/tr/td[1]/span/label/span/input')

        # 选择单据确定按钮
        select_order_determine = (by.XPATH, '(//button[@class="ant-btn ant-btn-primary"])[4]')

        # 保存并审核
        save_check = (by.CSS_SELECTOR, 'div.ant-modal-footer>button:nth-of-type(3)')